package com.talent.core.protocol.mqtt.codec.decoder;

import com.talent.core.protocol.mqtt.model.fix.TlMqttFixedHead;
import com.talent.core.protocol.mqtt.model.request.TlMqttHeartBeatReq;
import io.netty.buffer.ByteBuf;

/**
 * @ClassName：TlConnectDecoder
 * @Author: hszhou
 * @Date: 2024/11/30 15:12
 * @Description: 心跳包解码器
 */
public class TlMqttHeartBeatDecoder {

    public TlMqttHeartBeatReq build(ByteBuf buf, int type, int remainingLength){
        TlMqttFixedHead fixedHead = decodeFixedHeader(type, remainingLength);
        return new TlMqttHeartBeatReq(fixedHead);
    }

    TlMqttFixedHead decodeFixedHeader(int type,int remainingLength) {
        TlMqttFixedHead fixedHead =new TlMqttFixedHead();
        int messageType = type >> 4;
        fixedHead.setMessageType(messageType);
        fixedHead.setType(type);
        fixedHead.setLength(remainingLength);
        return fixedHead;
    }

}
